﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using wh40klbModel;
using wathammer40kListBuilder.ViewModel;

namespace wathammer40kListBuilder.View
{
    /// <summary>
    /// Interaction logic for NewInfantry.xaml
    /// </summary>
    public partial class NewInfantry : UserControl, Closable
    {
        private NewInfantryViewModel viewModel;


        public NewInfantry(Army a)
        {
            InitializeComponent();
            viewModel = new NewInfantryViewModel(a);
            this.DataContext = this.viewModel;
        }



        public ModalPanel panel
        {
            get;
            set;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                viewModel.SaveNewInfantry();

                panel.RaiseEndAction(this);
            }
            catch (InvalidOperationException ioe)
            {
                MessageBox.Show(ioe.Message+"\n"+ioe.StackTrace);
            }
            catch(Exception ex)
            {
                MessageBox.Show("heeelp\n"+ex.Message);
            }
        }
    }
}
